<template>
    <el-tab-pane :label="inorout === 2 ? '开票记录' : '收票记录'" name="invoice"
                 v-if="inorout !== 1">
        <z-table :title="inorout === 2 ? '开票记录' : '收票记录'" url="/do/select/invoice_perform"
                 :params="relatedParams" :columns="invoiceColumns" :size="5">
            <template #header$="">
                <z-action :label="inorout === 2 ? '添加开票' : '添加收票'" mode='dialog'
                          :fields="invoiceFields"
                          type='primary' url='/api/invoice/addInvoice' width="800px"/>
            </template>
            <template #action$="{ row }">
                <z-action label='详情' :data="row" mode='dialog' href='/finance/invoiceDetail' width='800px'
                          link
                          :map="{ id: 'id' }"/>
                <z-action v-if="inorout === 2" label='编辑' :data="row" mode='drawer'
                          href='/finance/invoiceEdit' link :map="{ id: 'id' }"/>
            </template>
        </z-table>
    </el-tab-pane>
</template>

<script>


export default {
    props: {
        params: Object,
        inorout: Object,
    },
    data() {
        return {
            relatedParams: null,
            invoiceColumns: [
                {label: "发票号码", name: "number"},
                {label: "发票类型", name: "invoiceType", code: "invoiceType"},
                {label: "金额", name: "amount", type: "money"},
                {label: "税率", name: "rate"},
                {label: "税额", name: "tax", type: "money"},
                {label: "日期", name: "date", type: "date"},
            ],
            invoiceFields: [
                {label: "关联合同", name: "related", default: this.params.contractId, visible: false},
                {label: "履约对象", name: "performParty", required: true},
                {label: "发票类型", name: "invoiceType", code: "invoiceType", default: 1, required: true},
                {label: "发票号码", name: "number", required: true},
                {label: "发票代码", name: "code"},
                {label: "发票金额", name: "amount", type: "money", required: true},
                {label: "税率", name: "rate", required: true, append: "%"},
                {label: "税额", name: "tax", type: "money", required: true},
                {label: "发票日期", name: "date", type: "date", required: true},
                {label: "分类", name: "type", default: this.inorout === 2 ? 1 : 0, visible: false},
                {label: "开票信息", name: "invoice", type: "map", visible: false},
                {label: "邮寄信息", name: "mail", type: "map", visible: false},
            ],
        }
    },
    created() {
        this.relatedParams = {related: this.params.contractId}
    },
    methods: {}
}
</script>
